<?php
header("Content-type: text/html; charset=utf-8");
define('RUNTIME_ALLINONE', true);
define('THINK_PATH', './Core');
define('APP_NAME', 'Yourphp');
define('APP_PATH', './Yourphp');
require(THINK_PATH."/Core.php");
App::run();

$map['domain']=$_SERVER['HTTP_HOST'];
if($website=M('website')->where($map)->find()){
	$_SESSION['website']['language']=$website['langzip'];  //语言包
	$_SESSION['website']['abbreviation']=$website['abbreviation'];  //国家简称
	$a='l='.$website['langzip'];
	if($_SESSION['website']['domain'] != $_SERVER['HTTP_HOST']){
		$_SESSION['website']['domain']=$website['domain'];
		$b=GetCurUrl();
		if(empty($_GET['l'])){
			if($b=='/'){
				$b='/index.php?l='.$website['langzip'];
			}else{
				$b=$b.'&'.$a;
			}
			echo "<script>location.href= '".$b."';</script>";
		}
	}
}
function GetCurUrl(){  
    if(!empty($_SERVER["REQUEST_URI"])){  
        $scriptName = $_SERVER["REQUEST_URI"];  
        $nowurl = $scriptName;  
    }else{  
        $scriptName = $_SERVER["PHP_SELF"];  
        if(empty($_SERVER["QUERY_STRING"])) $nowurl = $scriptName;  
        else $nowurl = $scriptName."?".$_SERVER["QUERY_STRING"];  
    }  
    return $nowurl;  
}  
?>